Fix revision table cleanup on delete
authorTim Starling <tstarling@wikimedia.org>
Fri, 4 Oct 2013 04:35:13 +0000 (14:35 +1000)
committerTim Starling <tstarling@wikimedia.org>
Fri, 4 Oct 2013 04:35:13 +0000 (14:35 +1000)
The ContentHandler branch inappropriately moved this essential
query to content-type-dependent code, despite the fact that revision
table cleanup needs to be done independently of content type. Before
r15707, the revision query was done immediately before the page query,
but it was moved down to allow it to be brought into the same
if (!$dbw->cascadingDeletes() ) block as the link updates. I have moved
it to immediately after the page delete, so that the rollback which has
since been added will not affect the expensive revision table query.

This should fix the database corruption we are seeing on some page
deletions (13 affected pages on enwiki, 14 on nlwiki, etc.)

Bug: 53687
Change-Id: I7a54c4416be07fb8cc7a5698e77927ccb24cbd6e

includes/LinksUpdate.php
includes/WikiPage.php

index 0b7393a..24f1679 100644 (file)
@@ -868,8 +868,6 @@ class LinksDeletionUpdate extends SqlDataUpdate {
 
                # If using cascading deletes, we can skip some explicit deletes
                if ( !$this->mDb->cascadingDeletes() ) {
-                       $this->mDb->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ );
-
                        # Delete outgoing links
                        $this->mDb->delete( 'pagelinks', array( 'pl_from' => $id ), __METHOD__ );
                        $this->mDb->delete( 'imagelinks', array( 'il_from' => $id ), __METHOD__ );
index 048dd68..c36d5d0 100644 (file)
@@ -2696,6 +2696,10 @@ class WikiPage implements Page, IDBAccessObject {
                        return $status;
                }
 
+               if ( !$dbw->cascadingDeletes() ) {
+                       $dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ );
+               }
+
                $this->doDeleteUpdates( $id, $content );
 
                // Log the deletion, if the page was suppressed, log it at Oversight instead